package QuestionNum_20_2;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class QuestionNum_20_2_hxj {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个字符串:");
        String str = sc.next();
        countLetter_hxj(str);
    }

    public static void countLetter_hxj(String str){
        int count = 0;
        char[] chars = str.toCharArray();
//        System.out.println(chars[0]);
        Map<Character,Integer> map = new HashMap<>();
        for (char c : chars) {
            map.put(c, map.get(c) != null ? map.get(c) + 1 : 1);
        }

        for (Map.Entry<Character, Integer> ci : map.entrySet()) {
            System.out.print(ci.getKey()+"("+ci.getValue()+")");
        }
    }
}
